package com.spzx.order.api.fallback;

import com.spzx.common.core.domain.R;
import com.spzx.order.api.OrderInfoFeignClient;
import com.spzx.order.api.domain.OrderInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @ClassName OrderInfoFeignClientFallbackFactory
 * @Author 波
 * @Date 2024/8/14 21:22
 */
@Component
@Slf4j
public class OrderInfoFeignClientFallbackFactory implements FallbackFactory<OrderInfoFeignClient> {
    @Override
    public OrderInfoFeignClient create(Throwable cause) {
        return new OrderInfoFeignClient() {
            @Override
            public R<OrderInfo> getByOrderNo(String orderNo, String source) {
                log.error("根据订单号查询订单信息失败" + cause.getMessage());
                return R.fail("根据订单号查询订单信息失败" + cause.getMessage());
            }
        };
    }
}
